package com.zl.autocode.controller.autocode;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zl.autocode.controller.base.AutocodeBaseController;
import com.zl.autocode.dto.autocode.previewTemplate.ReqPreviewTemplateAddDTO;
import com.zl.autocode.dto.autocode.previewTemplate.ReqPreviewTemplateDelDTO;
import com.zl.autocode.dto.autocode.previewTemplate.ReqPreviewTemplateDetailDTO;
import com.zl.autocode.dto.autocode.previewTemplate.ReqPreviewTemplateEditDTO;
import com.zl.autocode.dto.autocode.previewTemplate.ReqPreviewTemplateQueryDTO;
import com.zl.autocode.dto.autocode.previewTemplate.ReqPreviewTemplateStateDTO;
import com.zl.autocode.dto.autocode.previewTemplate.ResPreviewTemplateAddDTO;
import com.zl.autocode.dto.autocode.previewTemplate.ResPreviewTemplateDelDTO;
import com.zl.autocode.dto.autocode.previewTemplate.ResPreviewTemplateDetailDTO;
import com.zl.autocode.dto.autocode.previewTemplate.ResPreviewTemplateEditDTO;
import com.zl.autocode.dto.autocode.previewTemplate.ResPreviewTemplateQueryDTO;
import com.zl.autocode.dto.autocode.previewTemplate.ResPreviewTemplateStateDTO;
import com.zl.autocode.service.autocode.IPreviewTemplateService;
import com.zl.common.dto.ReqDTO;
import com.zl.common.dto.ResDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 可视化预览模板
 * @author ZL
 */
@Api(value="可视化预览模板",tags ="可视化预览模板")
@RestController("autocodePreviewTemplateController")
@RequestMapping("/autocode/previewTemplate")
public class PreviewTemplateController extends AutocodeBaseController {

    @Autowired
    private IPreviewTemplateService previewTemplateService;
    
    /**
     * 查询
     */
    @ApiOperation(value="可视化预览模板-查询")
    @RequestMapping(value="/list", method = RequestMethod.POST)
    public ResDTO<ResPreviewTemplateQueryDTO> listTemplate(@RequestBody ReqDTO<ReqPreviewTemplateQueryDTO> reqInfo) throws Exception{
        ResPreviewTemplateQueryDTO data = previewTemplateService.queryPreviewTemplateList(reqInfo);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @ApiOperation(value="可视化预览模板-详情")
    @RequestMapping(value="/detail", method = RequestMethod.POST)
    public ResDTO<ResPreviewTemplateDetailDTO> detailTemplate(@RequestBody ReqDTO<ReqPreviewTemplateDetailDTO> reqInfo) throws Exception{
        ResPreviewTemplateDetailDTO data = previewTemplateService.queryPreviewTemplateDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @ApiOperation(value="可视化预览模板-新增")
    @RequestMapping(value="/add", method = RequestMethod.POST)
        public ResDTO<ResPreviewTemplateAddDTO> addTemplate(@RequestBody ReqDTO<ReqPreviewTemplateAddDTO> reqInfo) throws Exception{
        ResPreviewTemplateAddDTO data = previewTemplateService.insertPreviewTemplateInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @ApiOperation(value="可视化预览模板-编辑")
    @RequestMapping(value="/edit", method = RequestMethod.POST)
        public ResDTO<ResPreviewTemplateEditDTO> editTemplate(@RequestBody ReqDTO<ReqPreviewTemplateEditDTO> reqInfo) throws Exception{
        ResPreviewTemplateEditDTO data = previewTemplateService.updatePreviewTemplateInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="可视化预览模板-删除")
    @RequestMapping(value="/del", method = RequestMethod.POST)
        public ResDTO<ResPreviewTemplateDelDTO> delTemplate(@RequestBody ReqDTO<ReqPreviewTemplateDelDTO> reqInfo) throws Exception{
        ResPreviewTemplateDelDTO data = previewTemplateService.deletePreviewTemplateInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @ApiOperation(value="可视化预览模板-状态更新")
    @RequestMapping(value="/state", method = RequestMethod.POST)
        public ResDTO<ResPreviewTemplateStateDTO> stateTemplate(@RequestBody ReqDTO<ReqPreviewTemplateStateDTO> reqInfo) throws Exception{
        ResPreviewTemplateStateDTO data = previewTemplateService.updatePreviewTemplateState(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="可视化预览模板-删除")
    @RequestMapping(value="/delTemplateAndDetail", method = RequestMethod.POST)
        public ResDTO<ResPreviewTemplateDelDTO> delTemplateAndDetail(@RequestBody ReqDTO<ReqPreviewTemplateDelDTO> reqInfo) throws Exception{
        ResPreviewTemplateDelDTO data = previewTemplateService.deletePreviewTemplateAndDetail(reqInfo);
        return successDATA(data); 
    }
}